import request from '@/utils/request'
//7、给角色分配菜单
export const AssignMenus2Role = (roleId, menuIds) => {
  return request({
    url: `/admin/system/roleMenu/assignMenus/${roleId}`,
    method: 'PUT',
    // [1,2,3]
    data: menuIds,
  })
}

//6、查询所有可用菜单 和角色已分配的菜单id集合
export const GetMenusByRoleId = roleId => {
  return request({
    url: `/admin/system/menu/role/listMenus/${roleId}`,
    method: 'GET',
  })
}

//1、查询级联关系的菜单集合
export const listMenus = () => {
  return request({
    url: `/admin/system/menu/listMenus`,
    method: 'GET',
  })
}
//2、删除
export const DeleteById = id => {
  return request({
    url: `/admin/system/menu/${id}`,
    method: 'DELETE',
  })
}
//3、根据id查询菜单
export const GetById = id => {
  return request({
    url: `/admin/system/menu/${id}`,
    method: 'GET',
  })
}
//4、根据id更新菜单
export const UpdateById = data => {
  return request({
    url: `/admin/system/menu`,
    method: 'PUT',
    data,
  })
}
//5、新增菜单
export const Save = data => {
  return request({
    url: `/admin/system/menu`,
    method: 'POST',
    data,
  })
}
